package com.keyinong.parkin.home.adapter;

import java.util.ArrayList;

import com.example.parkin.R;
import com.keyinong.parkin.home.bean.ImageFileName;
import com.keyinong.parkin.util.ImageUtilsLoaderFile;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;

public class TicketDetailImgAdapter extends BaseAdapter {
	Context context;
	ArrayList<ImageFileName> list;

	
	public TicketDetailImgAdapter(Context context, ArrayList<ImageFileName> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHandle handle;
		if (view == null) {
			handle = new ViewHandle();
			view = LayoutInflater.from(context).inflate(
					R.layout.item_grid_upticketimg, null);
			handle.img_ticketImg=(ImageView) view.findViewById(R.id.img_ticketImg);
		    handle.cb_img=(CheckBox) view.findViewById(R.id.cb_img);
		    handle.cb_img.setVisibility(View.GONE);
		    view.setTag(handle);
		}else{
			handle=(ViewHandle) view.getTag();
		}
		ImageUtilsLoaderFile.displayImage(context, list.get(position).getFilename(), 
				handle.img_ticketImg,R.drawable.img_noticelist_default);
//		handle.img_ticketImg.

		return view;
	}

	private class ViewHandle {
		ImageView img_ticketImg;
		CheckBox cb_img;

	}

}
